package com.laxia.enums;

import com.laxia.util.StringUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author weishuai
 * @since 2020/3/16
 */
@Getter
@AllArgsConstructor
public enum TokenTypeEnum {
    /**
     * 管理后台
     */
    MANAGE("M-");

    private String prefix;

    public static TokenTypeEnum valueByToken(String token) {
        return Arrays.stream(TokenTypeEnum.values()).filter(o -> StringUtil.startsWith(token, o.getPrefix())).findFirst().orElse(null);
    }
}
